﻿<%@ Page Language="C#" MasterPageFile="~/default.Master" AutoEventWireup="true" CodeBehind="MyProfile.aspx.cs"
    Inherits="BookNet.MyProfile" Title="My Profile" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>My Profile</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">
    <br />
    <br />
    <br />
    <h3>
        My Profile</h3>
    <p>
        &nbsp;</p>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="UserID"
                DataSourceID="SqlDataSource1" Height="50px" Width="653px">
                <Fields>
                    <asp:BoundField DataField="UserID" HeaderText="UserID" SortExpression="UserID" ReadOnly="True"
                        Visible="False" />
                    <asp:BoundField DataField="FullName" HeaderText="Full Name" SortExpression="FullName">
                    </asp:BoundField>
                    <asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender" />
                    <asp:BoundField DataField="Books" HeaderText="Books" SortExpression="Books" Visible="False" />
                    <asp:BoundField DataField="DateofBirth" HeaderText="Date of Birth" SortExpression="DateofBirth" />
                    <asp:BoundField DataField="Friends" HeaderText="Friends" SortExpression="Friends"
                        Visible="False" />
                    <asp:BoundField DataField="Favorites" HeaderText="Favorites" SortExpression="Favorites"
                        Visible="False" />
                    <asp:BoundField DataField="Faculty" HeaderText="Faculty" SortExpression="Faculty" />
                    <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
                    <asp:BoundField DataField="Avatar" HeaderText="Avatar" SortExpression="Avatar" />
                    <asp:TemplateField HeaderText="Bio" SortExpression="Bio">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Bio") %>' TextMode="MultiLine"
                                Width="550" Height="140"></asp:TextBox>
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Bio") %>'></asp:TextBox>
                        </InsertItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("Bio") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ShowHeader="False">
                        <EditItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                                Text="Update"></asp:LinkButton>
                            &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                                Text="Cancel"></asp:LinkButton>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                                Text="Edit"></asp:LinkButton>&nbsp;&nbsp;
                            <asp:LinkButton ID="LinkButton3" runat="server" OnClick="LinkButton1_Click">Change Password</asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Fields>
            </asp:DetailsView>
            <asp:Panel ID="Panel1" runat="server">
                <asp:ChangePassword ID="ChangePassword1" runat="server" Width="648px" 
                    ContinueDestinationPageUrl="~/Login.aspx" style="text-align: left">
                </asp:ChangePassword>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
    <br />
    <br />
    <br />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:booknetConnectionString1 %>"
        OnSelecting="SqlDataSource1_Selecting1" SelectCommand="SELECT * FROM [app_UserProfile] WHERE ([UserID] = @UserID)"
        UpdateCommand="UPDATE [app_UserProfile] SET [FullName] = @FullName, [Gender] = @Gender, [Books] = @Books, [DateofBirth] = @DateofBirth, [Friends] = @Friends, [Favorites] = @Favorites, [Faculty] = @Faculty, [Bio] = @Bio, [Phone] = @Phone, [Avatar] = @Avatar WHERE [UserID] = @UserID"
        DeleteCommand="DELETE FROM [app_UserProfile] WHERE [UserID] = @UserID" InsertCommand="INSERT INTO [app_UserProfile] ([UserID], [FullName], [Gender], [Books], [DateofBirth], [Friends], [Favorites], [Faculty], [Bio], [Phone], [Avatar]) VALUES (@UserID, @FullName, @Gender, @Books, @DateofBirth, @Friends, @Favorites, @Faculty, @Bio, @Phone, @Avatar)">
        <SelectParameters>
            <asp:Parameter Name="UserID" Type="Object" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="UserID" Type="Object" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="FullName" Type="String" />
            <asp:Parameter Name="Gender" Type="String" />
            <asp:Parameter Name="Books" Type="String" />
            <asp:Parameter Name="DateofBirth" Type="DateTime" />
            <asp:Parameter Name="Friends" Type="String" />
            <asp:Parameter Name="Favorites" Type="String" />
            <asp:Parameter Name="Faculty" Type="String" />
            <asp:Parameter Name="Bio" Type="String" />
            <asp:Parameter Name="Phone" Type="String" />
            <asp:Parameter Name="Avatar" Type="String" />
            <asp:Parameter Name="UserID" Type="Object" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="UserID" Type="Object" />
            <asp:Parameter Name="FullName" Type="String" />
            <asp:Parameter Name="Gender" Type="String" />
            <asp:Parameter Name="Books" Type="String" />
            <asp:Parameter Name="DateofBirth" Type="DateTime" />
            <asp:Parameter Name="Friends" Type="String" />
            <asp:Parameter Name="Favorites" Type="String" />
            <asp:Parameter Name="Faculty" Type="String" />
            <asp:Parameter Name="Bio" Type="String" />
            <asp:Parameter Name="Phone" Type="String" />
            <asp:Parameter Name="Avatar" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
    <br />
</asp:Content>
